package com.java.proxy;

import java.lang.reflect.Method;

/**
 * @program: java_basic_knowledge
 * @description:
 * @author: CaoYong
 * @create: 2021-04-07 14:03
 **/
public class CGLibDemo {

//    static class RealService {
//        public void sayHello() {
//            System.out.println("CGLib Hello");
//        }
//    }
//
//    static class SimpleInterceptor implements MethodInterceptor {
//
//        public Object intercept(Object object, Method method, Object[] args, MethodProxy proxy) throws Throwable{
//            System.out.println("before Hello");
//            Object result = proxy.invokeSuper(object, args);
//            System.out.println("after Hello");
//            return result;
//        }
//    }
//
//    private static <T> T getProxy(Class<T> cls) {
//        Enhancer enhancer = new EnHancer();
//        enhancer.setSuperclass(cls);
//        enhancer.setCallback(new SimpleInterceptor());
//        return (T) enhancer.create();
//    }
}
